#include "edge.h"

int main(){
    nodeAddress A,B,C,D,E,F;
    nodeList NL=CreateEmptyNodeList();;
    edgeList EL;
    edgeAddress EA;
    int L;
    char Path[100]="12ae312df3gf23grz",Up[100];
    float Time;
    UpperStr(Up,Path);
    
    
    
    A=AllocateNode(CharToString("A"),0.0025, 0.0025, 0.0025, 0.0025, true, true);
    B=AllocateNode(CharToString("B"),0.001, 0.002, 0.003, 0.004, true, true);
    C=AllocateNode(CharToString("C"),0.003, 0.003, 0.003, 0.003, false, true);
    D=AllocateNode(CharToString("D"),0.001, 0.001, 0.001, 0.001, true, true);
    E=AllocateNode(CharToString("E"),9999, 9999, 9999, 9999, true, false);
    F=AllocateNode(CharToString("F"),0.001, 0.001, 0.001, 0.001, true, true);
	
    EL=CreateEmptyEdgeList();
    
    printf("%d\n",EL);
    
    EA=AllocateEdge(A,B,2.5,0);
    AddEdge(&EL,EA);
    
    EA=AllocateEdge(A,C,1,0);
    AddEdge(&EL,EA);
    
    EA=AllocateEdge(B,C,2,2);
    AddEdge(&EL,EA);
    
    EA=AllocateEdge(B,E,2.5,0);
    AddEdge(&EL,EA);
    
    EA=AllocateEdge(D,C,0.5,0.5);
    AddEdge(&EL,EA);
    
    EA=AllocateEdge(C,E,3,3);
    AddEdge(&EL,EA);
    
    PrintEdgeHeader();
    EA=FIRST(EL);
    while (EA!=NULL) {
       PrintEdge(EA);
       EA=NEXT(EA);   
    }
    
    EA=FIRST(EL);
    while (EA!=NULL) {
       printf("%s->%s %.2f\n",(GetA(EA)->name).s,(GetB(EA)->name).s,GetDownload(EA));
       EA=NEXT(EA);   
    }
	
	GraphShortestPath(1000,DOWNLOAD,EL,E,A,&Time,Path);
	printf("E download ke A --- %s %f\n",Path,Time);
	
	GraphShortestPath(1000,UPLOAD,EL,E,A,&Time,Path);
	printf("E upload ke A --- %s %f\n",Path,Time);
	
	GraphShortestPath(1000,UPLOAD,EL,B,B,&Time,Path);
	printf("B upload ke B --- %s %f\n",Path,Time);
	
	GraphShortestPath(1000,DOWNLOAD,EL,B,B,&Time,Path);
	printf("B upload ke B --- %s %f\n",Path,Time);
	
	return 0;
}
